package us.nchu.tomtiger.dao;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import us.nchu.tomtiger.model.Admin;
import us.nchu.tomtiger.rowMapper.AdminRowMapper;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by XiongXuan on 2018/1/11.
 */
@Repository
public class AdminDao {
    @Resource
    private JdbcTemplate jdbcTemplate;

    public Admin query(String id) {
        String sql = "select * from admin where id='" + id + "';";
        return (Admin)jdbcTemplate.queryForObject(sql, new AdminRowMapper());
    }

    public List<Admin> queryAll() {
        String sql = "select * from admin";
        return jdbcTemplate.query(sql, new AdminRowMapper());
    }
}
